﻿package plugin.shenlu.view
{
    import com.core.*;
    import flash.events.*;
    import flash.external.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import uiresource.shenlu.*;
    import view.*;
    import view.mornExtends.*;
    import view.uilt.*;

    public class ShenluBuyView extends ShenluBuyViewUI
    {
        private var i:int;
        private var itemconfig:Object;
        private var storenewconfig:Object;
        private var msgArr:Array;

        public function ShenluBuyView()
        {
            this.itemconfig = ConfigDictionary.data.item;
            this.storenewconfig = ConfigDictionary.data.storeNew;
            this.msgArr = [];
            return;
        }// end function

        override protected function initializeView() : void
        {
            closeBtn1.addEventListener(MouseEvent.CLICK, this.closeClick);
            qianwangLabel.addEventListener(MouseEvent.CLICK, this.Onchongzhi);
            return;
        }// end function

        protected function Onchongzhi(event:MouseEvent) : void
        {
            if (!ItemUilt.canpay)
            {
                ModelProxy.change("movetips", "error", "功能尚未开放，敬请期待");
                return;
            }
            ExternalInterface.call("topay");
            return;
        }// end function

        override protected function createChildren() : void
        {
            loadUI("ShenluBuyView.xml");
            return;
        }// end function

        private function ListRender(param1:Component, param2:int) : void
        {
            var _loc_3:* = daojuList.array[param2];
            var _loc_4:* = param1.getChildByName("nameLabel") as Label;
            var _loc_5:* = param1.getChildByName("item") as FlashItem;
            var _loc_6:* = param1.getChildByName("img") as Image;
            var _loc_7:* = param1.getChildByName("moneyLabel") as Label;
            var _loc_8:* = param1.getChildByName("goumaiBtn") as Button;
            if (_loc_3)
            {
                _loc_4.text = _loc_3.name;
                _loc_5.data = _loc_3;
                _loc_7.text = _loc_3.nowprice;
                if (_loc_3.costtype == 2)
                {
                    _loc_6.url = "png.common.cs2_qian";
                }
                if (_loc_3.costtype == 3)
                {
                    _loc_6.url = "png.common.cs2_yuanbao";
                }
                _loc_8.clickHandler = new Handler(this.Ongoumai, [_loc_3.storeId]);
                param1.visible = true;
            }
            else
            {
                param1.visible = false;
            }
            return;
        }// end function

        private function Ongoumai(param1:int) : void
        {
            DialogMgr.instance.open(AppDialog.SC_BUY, {storeId:param1});
            return;
        }// end function

        public function shuaxinyb() : void
        {
            var _loc_1:* = UserData.getBagData();
            moneyLabel.text = _loc_1.bonus;
            money1Label.text = _loc_1.money;
            return;
        }// end function

        public function shopdatashow(param1:Array) : void
        {
            var _loc_2:Object = null;
            var _loc_3:int = 0;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            this.msgArr = [];
            this.i = 0;
            while (this.i < param1.length)
            {
                
                for each (_loc_2 in this.storenewconfig)
                {
                    
                    if (_loc_2.id == param1[this.i])
                    {
                        _loc_3 = _loc_2.itemid;
                        for each (_loc_4 in this.itemconfig)
                        {
                            
                            _loc_5 = this.itemconfig[_loc_3];
                            _loc_5.storeId = param1[this.i];
                        }
                        _loc_5.nowprice = _loc_2.nowprice;
                        _loc_5.costtype = _loc_2.costtype;
                        this.msgArr.push(_loc_5);
                    }
                }
                var _loc_6:String = this;
                var _loc_7:* = this.i + 1;
                _loc_6.i = _loc_7;
            }
            daojuList.array = this.msgArr;
            daojuList.renderHandler = new Handler(this.ListRender);
            this.shuaxinyb();
            return;
        }// end function

        protected function closeClick(event:MouseEvent) : void
        {
            this.visible = false;
            return;
        }// end function

    }
}
